package com.zgh.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by loop .
 * 2014/12/29.
 */
public class MapJson {

    public static Map<String, Object> outputDefaultMap() {
        Map<String, Object> objectMap = new HashMap<String, Object>();
        objectMap.put("status", 200);

        return objectMap;
    }

    public static Map<String, Object> outputSuccessMap(Object entity) {
        Map<String, Object> objectMap = new HashMap<String, Object>();
        objectMap.put("status", 200);
        objectMap.put(entity.getClass().getSimpleName(), entity);

        return objectMap;
    }

    public static Map<String, Object> outputSuccessMap(Object entity, String entityName) {
        Map<String, Object> objectMap = new HashMap<String, Object>();
        objectMap.put("status", 200);
        objectMap.put(entityName, entity);

        return objectMap;
    }

    public static Map<String, Object> outputSuccessMap(Map<String, Object> entity) {
        Map<String, Object> objectMap = new HashMap<String, Object>();
        objectMap.put("status", 200);
        objectMap.putAll(entity);
        return objectMap;
    }

    public static Map<String, Object> outputSuccessMap(List<Object> entities) {
        Map<String, Object> objectMap = new HashMap<String, Object>();
        objectMap.put("status", 200);
        objectMap.put("entities", entities);

        return objectMap;
    }

    public static <T> Map<String, Object> outputSuccessMap(List<T> entities, String entityName) {
        Map<String, Object> objectMap = new HashMap<String, Object>();
        objectMap.put("status", 200);
        objectMap.put(entityName, entities);

        return objectMap;
    }


    public static Map<String, Object> outputSuccessMap() {
        Map<String, Object> objectMap = new HashMap<String, Object>();
        objectMap.put("status", 200);

        return objectMap;
    }

    public static Map<String, Object> outputSuccessMap(String message) {
        Map<String, Object> objectMap = new HashMap<String, Object>();
        objectMap.put("status", 200);
        objectMap.put("msg", message);

        return objectMap;
    }

    public static Map<String, Object> outputErrorMap() {
        Map<String, Object> objectMap = new HashMap<String, Object>();
        objectMap.put("status", 500);
        objectMap.put("msg", "");

        return objectMap;
    }

    public static Map<String, Object> outputErrorMap(String message) {
        Map<String, Object> objectMap = new HashMap<String, Object>();
        objectMap.put("status", 500);
        objectMap.put("msg", message);
        return objectMap;
    }


}
